package base.game;

import java.io.Serializable;
import java.util.ArrayList;

import android.graphics.Canvas;
import android.graphics.Paint;

public class Player implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -3784926032980214907L;
	private ArrayList<BaseShip> myShips = new ArrayList<BaseShip>();
	
	public Player() {
	}
	
	public void startShips(Map map) {
		ShipSubmarine[] submarines = new ShipSubmarine[3];
		submarines[0] = new ShipSubmarine();
		submarines[1] = new ShipSubmarine();
		submarines[2] = new ShipSubmarine();
		submarines[0].move(map, 0, 0);
		submarines[1].move(map, 1, 0);
		submarines[2].move(map, 2, 0);
		myShips.add(submarines[0]);
		myShips.add(submarines[1]);
		myShips.add(submarines[2]);
		Ship2[] ship2s = new Ship2[2];
		ship2s[0] = new Ship2();
		ship2s[1] = new Ship2();
		ship2s[0].move(map, 0, 1);
		ship2s[1].move(map, 2, 1);
		myShips.add(ship2s[0]);
		myShips.add(ship2s[1]);
		Ship3 ship3 = new Ship3();
		ship3.move(map, 0, 2);
		myShips.add(ship3);
		ShipArmored armored = new ShipArmored();
		armored.move(map, 0, 3);
		myShips.add(armored);
		ShipAirCraft airCraft = new ShipAirCraft();
		airCraft.move(map, 0, 5);
		myShips.add(airCraft);
	}

	public void drawShips(Canvas canvas, Paint pAlpha) {
		for (int i = 0; i < myShips.size(); i++) {
			myShips.get(i).onDraw(canvas, pAlpha);
		}
	}

	public BaseShip selectShip(int x, int y) {
		for (int i = 0; i < myShips.size(); i++) {
			BaseShip myShip = myShips.get(i);
			if (myShip.collided(x, y)) {
				return myShip;
			}
		}
		return null;
	}
	
}
